/*
 * Copyright (c) 2021. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
 * Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
 * Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
 * Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
 * Vestibulum commodo. Ut rhoncus gravida arcu.
 */

package com.kason.fixlength;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.util.CharsetUtil;

/**
 * @author 卢清波
 * @date 2021/2/3 15:54
 */
public class FixLengthServerHandler extends SimpleChannelInboundHandler<MyMessage>
{
    private int count ;
    @Override
    protected void channelRead0(ChannelHandlerContext ctx, MyMessage msg) throws Exception
    {
        System.out.println("接收到数据:"+count++);
        System.out.println("数据长度:"+msg.getLength());
        System.out.println("数据内容："+new String(msg.getContent(), CharsetUtil.UTF_8));
    }
}
